//Jes.Upload.init({type:'IMP',upId:'ta_1','bId':id,'year':'2013','md':'impMsList',cb:'Jes.Mssub.upCb(da);'});
Jes.extend(Jes.Upload,{
	//upload.html上传页面
	_pa : null//临时参数
	,init : function(pa){
		pa.type=pa.type || 'BUSS',pa.upId=pa.upId||'ta_1',this._pa = pa;
		Jes.html('tit',pa.type=='img'?'图片上传':(pa.type=='video'?'视频上传':'附件上传'));
		if(pa.w) Jes.html('picinfo','是否压缩<input type="checkbox" id="isC" name="isC" class="checkbox" value="1"/>(不压缩请设置图片大小[宽'+pa.w+'-高'+pa.h+']象素)');
		upform.action='../../upload.shtml'.J(pa);//bid 和md excel导入 btype 保存
	}
	,upload : function(){
		var len = Jes.names(this._pa.upId+'.upname').length,num=this._pa.num,type=this._pa.type
		,name =type=='img'?'图片':(type=='video'?'视频':'附件'),file = Jes('upfile').value;
		//附件NUM限制
		if(num && num <=len){alert('上传'+name+'不能超过'+num+"项");return;}
		if(file == ''){alert('上传'+name+'不能为空');return;}
		if(type=='img' && !file.isPic()){alert('上传图片格式必须是jpg或者gif');return;}
		Jes.show('pBar');
		Jes.html('pBTxt','上传进度: 0%');
    	Jes("pBBCont").style.width = "0px";
    	Jes.disBtn();
    	window.setTimeout("Jes.Upload._proc()", 1000);
    	//return true;
		upform.submit();
	}
	,again : function(){
		Jes('upfile').outerHTML  = Jes('upfile').outerHTML;
		Jes.hide('pBar');
	}
	,_proc : function(){
		Jes.action('getINFO','UPPROC',function(da){
	    	if(da){
	    		Jes.html('pBTxt',da.procInfo);
	    		Jes('pBBCont').style.width = parseInt(da.procPer * 2.16)+'px';
	    	}
			if (!da || da.isProcess){
				window.setTimeout('Jes.Upload._proc()', 100);
			}else{
				Jes('pBBCont').style.width = '216px';
				var h='<input type="button" value="继续上传" onclick="Jes.Upload.again();"/>&nbsp;&nbsp;';
				if(Jes.Upload._pa.num==1) h='';
				Jes.html('pBTxt','<p><font color="red">'+da.procInfo+'</font></p><p>'+h+'<input type="button" value="关 闭" onclick="Jes.hide(\'pBar\');"/></p>');
				//Jes.hide("eBar");
				Jes.disBtn(false);
			}
	    });
	}
	//upload_response.jsp
	,cb : function(da){
		var w=this._pa.w,h=this._pa.h,upId=this._pa.upId,cb=this._pa.cb,cbEl=this._pa.cbEl,taEl=Jes(upId),tr,td;
		if(cb){
			eval(cb);//返回
			//eval(cb+'(da);');
		}else{
			try{
				if(this.param.type=='IMG' && 'gif|jpg'.indexOf(da.type) != -1){
					var style = Jes.isN(w)?'':' width="'+w+'" height="'+h+'"';
					tr = Jes.tr(taEl);
					td = Jes.td(tr,'<img src="'+da.httppath+'img/'+da.name +'" '+style+'><input type="hidden" id="'+upId+'.upname" name="'+upId+'.upname" value="'+da.name+'"/>',{align:'center'});
					td = Jes.td(tr,'<input type="button" value="删除" style="border:1px soild #000000;font-size:10px;" onclick="Jes.Upload.del(this,\''+da.id+'\',\''+da.name+'\',\''+cbEl+'\');"/>',{align:'center'});
					if(cbEl) Jes.val(cbEl,da.name);
				}else{
					tr = Jes.tr(taEl);
					td = Jes.td(tr,'<a href="../../download.shtml?name='+da.name+'&oldName='+da.oldname+'&isTemp=true">'+da.oldname+'</a>',{align:'center',height:'30px',bgColor:'#ffffff'});
					//if(this.param.type=='IMP'){
					//	td = Jes.td(tr,da.uplen);
					//}else{
					td = Jes.td(tr,da.upsize);
					//}
					td = Jes.td(tr,Jes.curDate());
					td = Jes.td(tr,'<input type="button" value="删除" style="border:1px soild #000000;font-size:10px;" onclick="Jes.Upload.del(this,\''+da.id+'\',\''+da.name+'\');"/>');
				}
		    }catch(e){
				alert("获得附件信息失败，请联系管理员。");
			}
		}
	}
});
